﻿@model MenuViewModel
@{
    bool isLoggedOn = new Kelper.Infrastructure.SessionAccountManager(Session).IsLoggedIn();
}

<nav class="menu">
@for (int i = 0; i < Model.Controllers.Count; i++)
{
    var c = Model.Controllers[i];
    var a = Model.Actions[i];
    var t = Model.Texts[i];
    var isCurrent = Model.IsCurrent(c, a);

    if (isLoggedOn && Model.Authenticated[i] || !isLoggedOn && Model.NotAuthenticated[i]) {
        @Html.ActionLink(t, a.ToLower(), c.ToLower(), null, new { @class = isCurrent ? "current" : null })
    }
}
@if (isLoggedOn)
{
    <div class="logout-button">
        @Html.ActionButton("Logout " + Session["user"], "logout", "user")
    </div>
}
else
{
    @Html.ActionLink("Not a member? Register here!", "register", "user", null, new { @class = "register-link" })
}
</nav>